<script>
function test(){
$.ajax({url:"echo.php", success:function(result){
$("div").text(result);}
})
}
</script>
#php 7.x
<?php
function php_func(){
echo " Have a great day";
}
php_func();
?>
<button onclick="test()"> Click </button>
<div> </div>